//
//  YSBookChapterModel.m
//  YSBookRead
//
//  Created by Kyson on 2018/11/6.
//  Copyright © 2018 YangShen. All rights reserved.
//

#import "YSBookChapterModel.h"

@implementation YSBookChapterModel

- (void)encodeWithCoder:(NSCoder *)aCoder {
    [aCoder encodeObject :self.bookID        forKey:@"bookID"];
    [aCoder encodeInteger:self.chapterIndex  forKey:@"chapterIndex"];
    [aCoder encodeObject :self.chapterID     forKey:@"chapterID"];
    [aCoder encodeObject :self.prevChapterID forKey:@"lastChapterID"];
    [aCoder encodeObject :self.nextChapterID forKey:@"nextChapterID"];
    [aCoder encodeObject :self.chapterName   forKey:@"chapterName"];
    [aCoder encodeObject :self.chapterURL    forKey:@"chapterURL"];
    [aCoder encodeBool   :self.haveCache     forKey:@"haveCache"];
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super init]) {
        self.bookID        = [aDecoder decodeObjectForKey:@"bookID"];
        self.chapterIndex  = [aDecoder decodeIntegerForKey:@"chapterIndex"];
        self.chapterID     = [aDecoder decodeObjectForKey:@"chapterID"];
        self.prevChapterID = [aDecoder decodeObjectForKey:@"lastChapterID"];
        self.nextChapterID = [aDecoder decodeObjectForKey:@"nextChapterID"];
        self.chapterName   = [aDecoder decodeObjectForKey:@"chapterName"];
        self.chapterURL    = [aDecoder decodeObjectForKey:@"chapterURL"];
        self.haveCache     = [aDecoder decodeBoolForKey:@"haveCache"];
    }
    return self;
}

@end
